var t = getApp(), a = require("../../../api.js");

Page({
    data: {
        positive: "",
        flag: 0,
        imgList: [],
        uploadList: [],
        carnum:0
    },
    onLoad: function(t) {
        this.data.uploadType = t.type;
        
    },
    upFontloadFile: function() {
        var t = this;
        wx.chooseImage({
            success: function(a) {
                var o = a.tempFilePaths;
                wx.showLoading({});
                var i = t.data.imgList;
                if (i.length + o.length > 9) return wx.showToast({
                    title: "最多上传9张",
                    icon: "none"
                }), !1;
                o.forEach(function(a, o) {
                    t.upload(a), i.push(a);
                }), t.setData({
                    imgList: i
                });
            }
        });
    },
    carnum(e){
        console.log(e.detail);
        e.detail 
        this.setData({
            carnum :  e.detail
        })
    },
    submit: function() {
        var t = this.data.uploadType;
       if( this.data.carnum != 1 && wx.showToast({
        title: '请输入车牌',
        icon: 'none'
      })) return false
        wx.setStorageSync(t, this.data.uploadList), wx.showToast({
            title: "确认成功"
        }), setTimeout(function() {
            wx.navigateBack();
        }, 800);
    },
    upload: function(o) {
        var i = this;
        if (this.data.flag >= 9) return wx.showToast({
            title: "最多上传9涨照片",
            icon: "none"
        }), !1;
        wx.uploadFile({
            url: a.driver.uploadcar,
            filePath: o,
            name: "file",
            formData: {
                access_token: wx.getStorageSync("access_token"),
                _uniacid: t.siteInfo.uniacid,
                _acid: t.siteInfo.acid
            },
            success: function(t) {
                if (wx.hideLoading(), 200 == t.statusCode) {
                    var a = JSON.parse(t.data), o = i.data.uploadList;
                    o.push(a.data), i.data.uploadList = o, console.log(o);
                }
            }
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});